#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>

using namespace std;

#define BEGINS(x) namespace x {
#define ENDS(x) } // end of namespace x

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a;
    for (int i = 0; i <= n; i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    int sum = 0;
    for (int i = 0; i <= n; i++) {
        sum += a[i] * pow(x, i);
    }
    cout << sum << endl;

    return 0;
}